package function

object CollectionOperation {
  //对数组进行处理，将操作抽象出来
  //处理完之后的结果返回一个新的数组
  def main(args: Array[String]): Unit = {
    val arr:Array[Int]=Array(12,34,67,57)

    def arrayOperation(arr: Array[Int], op: Int => Int): Array[Int] = {
      for (elem <- arr) yield op(elem)
    }
    //定义op函数
    def addOne(elem:Int):Int={
      elem+1
    }
    val newArray:Array[Int]=arrayOperation(arr,addOne)
    println(newArray.mkString(","))
  }

}
